<template>
    <el-dialog :title="title" :visible.sync="dialogVisible" width="1200px" append-to-body>
        <el-row class="mb8">
            <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download"  :loading="download" :disabled="download" @click="handleExport">导出</el-button>
            </el-col>
        </el-row>
        <el-table  v-loading="loading" :data="tableData" border script>
            <el-table-column label="店铺" prop="shop_name" min-width="120"> </el-table-column>
            <el-table-column label="图片" min-width="80">
                <template slot-scope="scope">
                    <ImageUploadImg v-model="scope.row.imange_url" :readOnly="true"></ImageUploadImg>
                </template>
            </el-table-column>
            <el-table-column label="订单ID" prop="order_id" min-width="120"></el-table-column>
            <el-table-column label="sku" prop="sku" min-width="140"></el-table-column>
            <el-table-column label="件数" prop="num" min-width="100"></el-table-column>
            <el-table-column label="订单编号" prop="order_number" min-width="120"></el-table-column>
            <el-table-column label="物流单号" prop="track_number" min-width="180"></el-table-column>
            <el-table-column label="发货仓库" prop="hwc_warehouse" min-width="100">
                <template slot-scope="scope">
                    <span>{{ scope.row.hwc_warehouse == 1 ? '海外仓' : '江夏仓'}}</span>
                </template>
            </el-table-column>
            <el-table-column label="创建时间" prop="create_time" width="160"></el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="getList" />
        <div slot="footer" class="dialog-footer"></div>
        
    </el-dialog>
</template>

<script>
import { getExplodeDetail, exportOrderSplitInfo } from '@/api/order'
import { exportFile } from '@/utils/index'

export default {
    name: 'ProductDialog',
    props: {
        value: {
            type: Boolean,
            default: false,
            required: true,
        },
        params: {
            type: Object,
            default: () => {},
        },
    },
    data() {
        return {
            loading: false,
            download: false,
            tableData: [],
            total: 0,
            pageInfo: {
                page: 1,
                limit: 10,
            },
            queryParams: {
                order_id: this.params.order_id,
            },
        }
    },
    computed: {
        title() {
            return `订单拆分详情`
        },
        dialogVisible: {
            get() {
                return this.value
            },
            set(val) {
                this.$emit('input', val)
            },
        },
    },
    mounted() {
        this.getList()
    },
    methods: {
        handleExport() {
            this.download = true
            const qyparams = {
                ...this.pageInfo,
                ...this.queryParams,
            }
            exportOrderSplitInfo(qyparams)
                .then(res => {
                    console.log(res)
                    exportFile(res, () => {
                        this.download = false
                    })
                })
                .catch(err => {
                    console.log(err)
                    this.download = false
                })
        },
        getList() {
            this.loading = true
            const params = { ...this.queryParams, ...this.pageInfo }
            getExplodeDetail(params)
                .then(res => {
                    this.tableData = res.data.list || []
                    this.total = res.data.total || 0
                })
                .finally(() => {
                    this.loading = false
                })
        },
    },
}
</script>

<style>

</style>
